package severlet;

import bean.Guarantee;
import dao.GuaranteeDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet(name = "AdminGuaranteeServlet", value = "/AdminGuaranteeServlet")
public class AdminGuaranteeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");

        //调用dao层查询
        GuaranteeDao guaranteeDao=new GuaranteeDao();
        ArrayList<Guarantee> allGuarantee = guaranteeDao.getAllGuarantee();
        //存入session
        request.getSession().setAttribute("adminGuarantee",allGuarantee);
        //跳转
        request.getRequestDispatcher("admin_guarantee.jsp").forward(request,response);
    }
}
